<?
	/*
	 * @since 2012.03.27
	 * @author Charles Koh
	 * @returns {Register page 1}
	 */
	session_start();
	$g_userId = $_SESSION['userid'];
	
	if($g_userId) {
		echo "Aledy to sign-in..";
	} else {
?>
<html>
<head>
	<link rel="stylesheet" href="../../css/common.css"/>
	<script type="text/javascript" src="../../js/common.js"></script>
	<script>
	var sponsorId = null,
		sponsorName = null,
		sponsorPhoto = null;
	function find_sponsor()
	{
		ajax.request({
			url:"find_sponsor.php",
			type:"GET",
			data:"id=" + document.step_1_sponsor.sponsor_id.value,
			dataType:"json",
			successCB: function (json) {
				alert(json.message);
				if (json.data) {
					sponsorId = json.data[0];
					sponsorName = json.data[1];
					sponsorPhoto = json.data[2];
					document.step_1_sponsor.sponsor_id.disabled = true;
				} else {
					sponsorId = sponsorName = sponsorPhoto = null;
				}
				document.step_1_sponsor.sponsor_id.value = sponsorId;
				document.getElementById('reg_sponsor_id').innerHTML = sponsorId;
				document.getElementById('reg_sponsor_name').innerHTML = sponsorName;
				//document.getElementById('reg_profile_photo').src = sponsorPhoto;
			}
		});
	}

	function check_input()
	{
		if (!document.step_1_sponsor.sponsor_id.value)
		{
			alert("No input id");    
			document.step_1_sponsor.sponsor_id.focus();
			return;
		}
		 
		if (!document.step_1_sponsor.sponsor_id.disabled) {
			alert("Check sponsor ID");    
			document.step_1_sponsor.sponsor_id.focus();
			return;
		}
		document.step_1_sponsor.sponsor_id.disabled=false;
		document.step_1_sponsor.submit();
	}

	function reset_form()
	{
		document.step_1_sponsor.sponsor_id.value = "";
		      
		document.step_1_sponsor.sponsor_id.focus();

		return;
	}
	

	</script>
</head>

<body>
	<!--Step 1-->
	<div id="reg_step_1">
		<b>Register</b><br/><br/>
		<span>1 Step: Select Sponser</span><br/><br/>
		<form name="step_1_sponsor" action="register_form_2.php" method="POST">
		<table border=0 cellspacing=0 cellpadding=0 align=center width="682" >
			<tr>
				<td bgcolor=DEDEDE>Sponsor's Member ID or Username</td>
				<td><input type="text" name="sponsor_id"</td>
				<td><input type="button" value="Find Sponsor" onclick="find_sponsor()"/></td>
			</tr>
			<tr>
				<td colspan="3">
					<table id="sponsor_profile" align="center">
						<tr>
							<td rowspan="2" width="400px" align="center">Your Sponsor Information</td>
							<td rowspan="2" width="200px" align="center"><img id="reg_profile_photo"/>Profile<br/>Photo</td>
							<td width="200px" align="left">Member ID:</td>
							<td id="reg_sponsor_id" width="200px" align="left"></td>
						</tr>
						<tr>
							<td width="200px" align="left">Name:</td>
							<td id="reg_sponsor_name" width="200px" align="left"></td>
						</tr>
						<tr><td colspan="4"> </td></tr>
						<tr><td colspan="4" align="center">
							<input type="button" value="to reserve" onclick="check_input()"/>
							<input type="button" value="to change" onclick="javascript:document.step_1_sponsor.sponsor_id.disabled=false;"/>
						</td></tr>
					</div>
				</td>
			</tr>	
		</table>
		</form>
	</div><!--Step 1-->
  </body>
</html>

<?
	}
?>